home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / WINER.ZIP / FAR$.ASM < prev    next >
Assembly Source File  |  1992-05-13  |  3KB  |  93 lines

  1. ;FAR$.ASM, support routines for use with PDS far strings
  2.  
  3. ;Copyright (c) 1991 Ethan Winer
  4. ;with special thanks to Jay Munro
  5.  
  6.  
  7. ;StringInfo
  8. ;
  9. ;StringInfo returns the length, segment, and address of a
  10. ;PDS far string, and preserves all necessary registers.
  11. ;
  12. ;   Input:
  13. ;       DS:SI = address of string descriptor
  14. ;
  15. ;   Output:
  16. ;       AX = address of string data
  17. ;       DX = segment of string data
  18. ;       CX = length of string
  19.  
  20. .Model Medium, Basic
  21.  
  22.     Extrn StringAddress:Proc    ;these are part of PDS
  23.     Extrn StringLength:Proc
  24.     Extrn StringAssign:Proc
  25.  
  26. .Code
  27.  
  28. StringInfo Proc Uses SI DI BX ES
  29.  
  30.   Pushf                   ;we can't include Flags in Uses
  31.  
  32.   Push ES                 ;save ES for later
  33.   Push SI                 ;pass incoming descriptor
  34.   Call StringAddress      ;call the PDS routine
  35.  
  36.   Pop  ES                 ;retrieve ES for StringLength
  37.   Push AX                 ;save offset and segment
  38.   Push DX                 ;  returned by StringAddress
  39.  
  40.   Push SI                 ;pass incoming descriptor
  41.   Call StringLength       ;get the length
  42.   Mov  CX,AX              ;copy the length to CX
  43.  
  44.   Pop  DX                 ;retrieve the saved Segment
  45.   Pop  AX                 ;and address
  46.  
  47.   Popf                    ;restore flags
  48.   Ret                     ;return to caller
  49.  
  50. StringInfo Endp
  51.  
  52.  
  53.  
  54. ;MakeString
  55. ;
  56. ;MakeString creates a string descriptor for far strings
  57. ;by setting up and calling the routines that come with
  58. ;BASIC PDS.  This subroutine merely consolidates the code
  59. ;that is needed to create a string.  If the destination
  60. ;length is non-zero, then the assigned string is actually
  61. ;placed at the address pointed to by DS:DI.
  62. ;
  63. ;   Input:
  64. ;       DX = segment of source data
  65. ;       AX = address of source data
  66. ;       CX = length of source string
  67. ;       DS = segment of destination
  68. ;       DI = address of destination
  69. ;       BX = length of destination, or zero to assign
  70. ;            a variable length string
  71. ;
  72. ;   Output:
  73. ;       If BX was 0, DS:[DI] holds the string descriptor
  74. ;       If non-zero, DS:[DI] is the start of the new copy
  75.  
  76. .Model Medium, BASIC
  77. .Code 
  78.  
  79. MakeString Proc Uses DS 
  80.  
  81.   Push DX            ;push the segment of the source string
  82.   Push AX            ;push the address of the source string
  83.   Push CX            ;push the string length
  84.   Push DS            ;push the segment of the destination string
  85.   Push DI            ;push the address of the destination string
  86.   Push BX            ;push the destination string length
  87.  
  88.   Call StringAssign  ;call BASIC to assign the string
  89.   Ret                ;return to caller
  90.  
  91. MakeString Endp
  92. End
  93.